/* ptsdd.t   BOM STRUCTURE SUBSTITUTE PUR PCT DELETE TRIGGER                 */

	TRIGGER PROCEDURE FOR DELETE OF PTSD_DET.

    {mfdeclre.i }
    define new shared work-table wf_old_ptsd_det like ptsd_det.

	HK:
	do:
        if can-find(first dt_mstr where dt_table = "ptsd_det" and dt_type = "SYNC") then
            run CreateSyncFlag(input "DEL", input recid(ptsd_det), input "ptsd_det").

        if not can-find ( first dt_mstr where dt_table = "ptsd_det" and dt_type = "DEL" ) then leave HK.
        
        if not can-find ( first wf_old_ptsd_det ) then do:
            create wf_old_ptsd_det.
            if recid(wf_old_ptsd_det)= -1 then .
        end.
        
        buffer-copy ptsd_det to wf_old_ptsd_det no-error.

        for first dt_mstr no-lock where dt_table = "ptsd_det" and dt_type = "DEL" :
        
    	    run CreateDthist(input dt_table, input dt_field, input dt_type, input "", input "", 
        	    input recid(ptsd_det), input ptsd_det.ptsd_part, input ptsd_det.ptsd_sub_part, input ptsd_det.ptsd_vend, input "",
        	    input "", input "", input "", input "") .
			
        end.
	end.

{hkdttrans.i}
